import csv

# 新建一个 fliggy.csv 文件,w 表示是新创建一个文件, encoding 为 utf-8-sig，中文能正常显示,
# newline="" 不能省略，省略了之后，会换行
csvFileName="csv1.csv"
with open(csvFileName, "w", encoding='utf-8-sig', newline="") as f:
    csv_write = csv.writer(f)
    csv_head = ["名称", "月", "日", "价格", "余量"]
    csv_write.writerow(csv_head)

row = ['product.text', 'month.text', 'day.text', 'price.text', 'number.text']
# encoding 为 utf-8-sig, 中文能正常显示, 不信的话, 换成 utf-8试试
out = open(csvFileName, "a+", encoding='utf-8-sig', newline="")
csv_writer = csv.writer(out, dialect="excel")
csv_writer.writerow(row)
out.close()  


import csv
csvFileName="class02\\csv1.csv"
# csvFileName="csv1.csv"
table1=[]
with open(csvFileName, "r", encoding='utf-8-sig', newline="") as f:
    csv_read = csv.reader(f)
    header=next(csv_read)
    print(header)
    for row in csv_read:
       print(row) 
       table1.append(row)

print(table1)